package com.goldsprite.gameframeworks.ecs.system;

import com.goldsprite.gameframeworks.timeline.TimeLineTask;

import java.util.ArrayList;
import java.util.List;

@GameSystemInfo(type = GameSystemInfo.SystemType.BOTH)
public class TimeLineTaskSystem extends BaseSystem {
	private final List<TimeLineTask> fixedTimeLineTasks = new ArrayList<>();
	private final List<TimeLineTask> timeLineTasks = new ArrayList<>();
	@Override
	public void fixedUpdate(float fixedDelta) {
		fixedTimeLineTasks.removeIf(t -> t.setDelta(fixedDelta).execute().isCompleted);
	}

	@Override
	public void update(float delta) {
		timeLineTasks.removeIf(t -> t.setDelta(delta).execute().isCompleted);
	}

	public void executeFixedTimeLineTask(TimeLineTask task) {
		fixedTimeLineTasks.add(task);
	}
	public void executeTimeLineTask(TimeLineTask task) {
		timeLineTasks.add(task);
	}
}
